﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Taoyl.CodeTraceControlLib
{
    public partial class DeviceStatics : UserControl
    {
        public DeviceStatics()
        {
            InitializeComponent();
            this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            this.SetStyle(ControlStyles.DoubleBuffer, true);
            this.SetStyle(ControlStyles.ResizeRedraw, true);
            this.SetStyle(ControlStyles.Selectable, true);
            this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            this.SetStyle(ControlStyles.UserPaint, true);
        }

        private string titleName = "设备状态显示";
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("设置或获取标题名称")]
        public string TitleName
        {
            get { return titleName; }
            set { titleName = value; this.lbl_Title.Text = titleName; }
        }

        private int totalCount=6;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("设置或获取设备总共数量")]
        public int TotalCount
        {
            get { return totalCount; }
            set { 
                if (totalCount != value)
                {
                    totalCount = value;
                    this.meter_Device.MaxValue = totalCount;
                    this.lbl_Total.Text=totalCount.ToString();
                    this.lbl_Offline.Text = (totalCount - onLineCount).ToString();
                }
            }
        }

        private int onLineCount = 5;
        [Browsable(true)]
        [Category("自定义属性")]
        [Description("设置或获取设备在线数量")]
        public int OnLineCount
        {
            get { return onLineCount; }
            set
            {
                if (onLineCount != value)
                {
                    onLineCount= value;
                    this.meter_Device.ActualValue = onLineCount;
                    this.lbl_Online.Text = onLineCount.ToString();
                    this.lbl_Offline.Text = (totalCount-onLineCount).ToString();
                }
            }
        }
    }
}
